From 1e66d26cbd1abcc2b1350f1295439d68eeedc527 Mon Sep 17 00:00:00 2001 From: Alastair Tse Date: Fri, 6 Oct 2006 17:34:49 +0100 Subject: [PATCH] [XEND] Save device updates to VM configuration via Xen API Signed-off-by: Alastair Tse --- tools/python/xen/xend/XendAPI.py | 2 ++ tools/python/xen/xend/XendDomain.py | 15 ++++++++++----- tools/python/xen/xend/XendDomainInfo.py | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index a33345e295..dc9595f94e 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -963,6 +963,7 @@ class XendAPI: dom = xendom.get_vm_by_uuid(vbd_struct['VM']) try: vbd_ref = dom.create_vbd(vbd_struct) + xendom.managed_config_save(dom) return xen_api_success(vbd_ref) except XendError: return xen_api_error(XEND_ERROR_TODO) @@ -1029,6 +1030,7 @@ class XendAPI: dom = xendom.get_vm_by_uuid(vif_struct['VM']) try: vif_ref = dom.create_vif(vif_struct) + xendom.managed_config_save(dom) return xen_api_success(vif_ref) except XendError: return xen_api_error(XEND_ERROR_TODO) diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index dee31a331b..361c7613c5 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -143,7 +143,7 @@ class XendDomain: running = self._running_domains() managed = self._managed_domains() - # add all active domains, replacing managed ones + # add all active domains for dom in running: if dom['domid'] != DOM0_ID: try: @@ -160,12 +160,14 @@ class XendDomain: dom_name = dom.get('name', 'Domain-%s' % dom_uuid) try: - # instantiate domain if not started. - if not self.domain_lookup_nr(dom_name): + running_dom = self.domain_lookup_nr(dom_name) + if not running_dom: + # instantiate domain if not started. new_dom = XendDomainInfo.createDormant(dom) self._add_domain(new_dom) - # keep track of maanged domains - self._managed_domain_register(new_dom) + self._managed_domain_register(new_dom) + else: + self._managed_domain_register(running_dom) except Exception: log.exception("Failed to create reference to managed " "domain: %s" % dom_name) @@ -237,6 +239,9 @@ class XendDomain: @raise XendError: fails to save configuration. @rtype: None """ + if not self.is_domain_managed(dominfo): + return # refuse to save configuration this domain isn't managed + if dominfo: domains_dir = self._managed_path() dom_uuid = dominfo.get_uuid() diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index a4afe1d73e..40fbd1106d 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -265,7 +265,7 @@ def createDormant(xeninfo): log.debug("XendDomainInfo.createDormant(%s)", xeninfo) - # Remove domid and uuid do not make sense for non-running domains. + # domid does not make sense for non-running domains. xeninfo.pop('domid', None) vm = XendDomainInfo(XendConfig(cfg = xeninfo)) return vm -- 2.30.2